#include<stdlib.h>
#include<stdio.h>

//˳
int seq_search(int array[] ,int n,int k, int seek_seq[] ){
	int a;
	for(a=0;a<n; a++){
		if(array[a] == k){
			seek_seq[a]=a;
			return 0;
		}else{
			seek_seq[a]=a;
		}	
	} 
	return -1;
}

int bin_search(int array[] ,int n,int k, int seek_seq[]){
	int low,high,mid,i=0;
	for(low=0,high=n;low<=high;){		
		mid = (high+low-1)/2;
		if(array[mid] == k){
			seek_seq[i]=mid;
			return mid;
		}
		if(array[mid] < k)
		{
			seek_seq[i]=mid;
			low = mid +1;
		}else
		{
			seek_seq[i]=mid;
			high = mid - 1 ;
		}	
		i++;
	}
	return -1;
}
void main(){
	int a[6]={1,3,5,10,12,15};
	int b[6];
	//printf("%d\n",seq_search(a,6,0,b));
	printf("%d",bin_search(a,6,15,b));
	system("pause");
}
